//
//  DetailTaskViewController.m
//  iTimeline
//
//  Created by Mobioneer HV 01 on 1/9/13.
//  Copyright (c) 2013 Mobioneer Co., Ltd. All rights reserved.
//

#import "DetailTaskViewController.h"

#import "Data.h"
#import "Common.h"
#import "AppDelegate.h"

@interface DetailTaskViewController ()

@end

@implementation DetailTaskViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self config];
}

//

- (void)viewWillAppear:(BOOL)animated
{
}
- (void) config
{
    self.title = @"Detail Task";
    self.taskName.text = self.data.taskName;
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
    [dateFormatter setDateStyle:NSDateFormatterShortStyle];
    
    NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"vi_VN"];
    [dateFormatter setLocale:usLocale];
    self.time.text = [dateFormatter stringFromDate:self.data.time];
    
    switch ([self.data.priority intValue]) {
        case 1:
            self.priority.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"green-tick.png"]];
            break;
        case 2:
            self.priority.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"blue-tick.png"]];
            break;
        case 3:
            self.priority.backgroundColor = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"red-tick.png"]];
            break;
        default:
            break;
    }
    NSString *temp = @"";
    for (int i=0; i<[self.data.repeat length]; i++) {
        int character = [self.data.repeat characterAtIndex:i];
        NSLog(@"%i",character);
        if(character ==  49)
        switch (i) {
            case 0:
                temp = [temp stringByAppendingString:@"Mon "];
                break;
            case 1:
                temp = [temp stringByAppendingString:@"Tue "];
                break;
            case 2:
                temp = [temp stringByAppendingString:@"Wed "];
                break;
            case 3:
                temp = [temp stringByAppendingString:@"Thu "];
                break;
            case 4:
                temp = [temp stringByAppendingString:@"Fri "];
                break;
            case 5:
                temp = [temp stringByAppendingString:@"Sat "];
                break;
            case 6:
                temp = [temp stringByAppendingString:@"Sun "];
                break;
            default:
                break;
        }
    }
    if([temp length] == 0) self.repeat.text = @"Never";
    else self.repeat.text = temp;
    self.sound.text = self.data.sound;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
